const tool = {
  getDate: (date = new Date()) => {
    let time = JSON.stringify(date).replace(/"/g, '').split("T")
    return `${time[0]} ${time[1].split(".")[0]}`
  },
  query: (db, sql) => {
    return new Promise((resolve, reject) => {
      try {
        db.query(sql, [], (data) => {
          console.log(data, "query");
          resolve(data)
        })
      } catch (error) {

      }
    })
  },
  asyncMap: (arr, callback) => {
    return Promise.all(arr.map(async () => {
      return callback
    }))
  }
}
Array.prototype.AsyncMap = function (callback) {
  return Promise.all(this.map(async e => {
    return callback(e)
  }))
}
module.exports = tool